define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form,undefined) {

    var Controller = {
        index: function () {


            _init = {
                index_url: 'bet/bet/index',
                // add_url: 'user/user/add',
                // edit_url: 'user/user/edit',
                // del_url: 'user/user/del',
                // multi_url: 'user/user/multi',
                table: 'apply_bet'
            };

            // 初始化表格参数配置
            Table.api.init({
                extend: _init
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        // {checkbox: true},
                        {field: 'id', title: '订单ID', sortable: true,operate: false},
                        {field: 'apply.tel', title: '客户手机号码', operate: 'LIKE',formatter: Table.api.formatter.search},
                        {field: 'apply.zhimafen', title: '芝麻分', operate: '=', sortable: true},
                        {field: 'user.username', title: '商户账户', operate: 'LIKE',formatter: Table.api.formatter.search},
                        {field: 'score', title: '消费积分', operate: '=', sortable: true},
                        {field: 'create_time', title: '创建时间', formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                        {field: 'status', visible: false,title: __('Status'),formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}},
                    ]
                ]
            });

            // 为表格绑定事件
            // Controller.api.bindevent();
            Table.api.bindevent(table);

        },

        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
            formatter: {

                custom: function (value, row, index) {
                    //添加上btn-change可以自定义请求的URL进行数据处理
                    return '<a class="btn-change text-success" data-url="user/user/multi" data-id="' + row.id + '" data-params="status=hidden"><i class="fa ' + (row.title == '' ? 'fa-toggle-off' : 'fa-toggle-on') + ' fa-2x"></i></a>';
                }
            }


        }
    };
    return Controller;


});